if exists (select 1
          from sysobjects
          where  id = object_id('bd_fn_timeToMin')
          and type in ('IF', 'FN', 'TF'))
   drop function bd_fn_timeToMin
go

CREATE function bd_fn_timeToMin (@time varchar(max))
RETURNS int
BEGIN
 
  DECLARE @result int = 0
	
	if(CHARINDEX(':',@time)>0)
	BEGIN
	
		SET @result = dbo.F_split1(@time,1,':')*60+dbo.F_split1(@time,2,':');
		
	END
	
  RETURN @result
END